package cn.wolfcode.trip.base.domain;

import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Getter;
import lombok.Setter;
import org.springframework.format.annotation.DateTimeFormat;

import java.util.Date;

/**
 * 购买商品表
 */
@Getter@Setter
public class Buy extends BaseDomain {
    public static final int STATUS_NORMAL=1;//待发货
    public static final int STATUS_DELIVER=2;//已发货
    public static final int STATUS_CART=3;//待付款
    public static final int COLLECT_NORMAL=0;//未收藏
    public static final int COLLECT_TRUE=1;//收藏

    private Commodity commodity;//商品

    private User user;//用户

    private String name;//收货人名

    private String tel;//收货人电话

    private String site;//收货人地址

    private Integer status=STATUS_NORMAL;//商品状态

    private Integer collect=COLLECT_NORMAL;//收藏商品

    @DateTimeFormat(pattern = "yyyy-MM-dd")
    @JsonFormat(pattern="yyyy-MM-dd",timezone="GMT+8")
    private Date time;//下单时间

    public String getStatueName(){
        if (status==STATUS_NORMAL){
            return "待发货";
        }else if (status==STATUS_DELIVER){
            return "已发货";
        }else if (status==STATUS_CART) {
            return "待付款";
        }
        return "";
    }

    public String getCollectName() {
        if (collect == COLLECT_NORMAL) {
            return "未收藏";
        } else if (collect == COLLECT_TRUE) {
            return "收藏";
        }
        return "";
    }
}